﻿using System.Collections.Generic;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Data;
using System.Linq;

namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        /// <summary>
        /// GetJob is used to collect the tasks to finish the order creation
        /// </summary>
        /// <param name="FInterID"></param>
        /// <returns></returns>
        public DataSet SJHWBLABLE(DataSet db)
        {

            ArrayList tbs = new ArrayList() { "A", "B", "C" };
            string a = (string)tbs[0];
            DataSet Result = new DataSet();
            DataSet Return = new DataSet();

            try
            {
                string processed = ""; 
               
                foreach (DataRow dwWB in db.Tables["WBBST"].Rows)
                { 
                    exAgent.SetCellValue(3, 3, Helpers.Helper.GetGB2312Value(dwWB["WBBFILLER"].ToString().Trim()) + "-" + dwWB["WBBKOMMNR"].ToString().Substring(0, 1));
                    exAgent.SetCellValue(4, 3, Helpers.Helper.GetGB2312Value(dwWB["WBBART"].ToString().Trim()));
                    exAgent.SetCellValue(5, 3, Helpers.Helper.GetGB2312Value(dwWB["WBBDPART"].ToString().Trim() + dwWB["WBBDPART2"].ToString().Trim()));
                    exAgent.SetCellValue(6, 3, dwWB["WBBNEUDAT"].ToString().Trim());
                    exAgent.SetCellValue(7, 3, (Convert.ToDouble(dwWB["WBBSSTKLG"].ToString())*0.001).ToString().Trim());
                    processed = dwWB["WBBZENSURKZ"].ToString().Trim();
                    if (processed=="A")
                    {
                        processed = "1";
                    }
                    if (processed == "B")
                    {
                        processed = "2";
                    }
                    if (processed == "C")
                    {
                        processed = "3";
                    }
                    if (processed == "D")
                    {
                        processed = "4";
                    }
                    exAgent.SetCellValue(7, 5, dwWB["WBBZMT"].ToString().Trim()+"-"+processed);
                    exAgent.SetCellValue(8, 3, dwWB["WBBKOMMNR"].ToString().Trim());
                    exAgent.SetCellValue(8, 5, dwWB["WBBNEUBEN"].ToString().Trim());
                    exAgent.SetCellValue(9, 2, "*" + dwWB["WBBSTKNR"].ToString().Trim() + "*");
                    exAgent.Save();
                    exAgent.FileName = DestFile;
                    DirectPrint(DestFile); 
                } 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {

            }
            return Return;
        }

    }
}
